*** Settings ***
Suite Setup       Set Log Level    trace
Test Setup        One APP Login    &{appUser1}[name]    &{appUser1}[pwd]
Resource          ../../../Resources_Config.robot

*** Test Cases ***
发布问题-正常流程
    [Documentation]    【接口信息】
    ...    POST
    ...    /add-question
    ...
    ...    【测试步骤】
    ...    1.调用接口，发布问题
    ...
    ...    【预期结果】
    ...    1.状态码200
    ...    2.body中returnStatus值是SUCCEED
    [Tags]    L0
    #构造请求体
    ${content}    Random Chn    100    #随机生成长度为100的字符串
    ${imgUrlList}    Create List    &{imgUrlDict}[golf]    &{imgUrlDict}[jetta]
    ${postdata}    Create Dictionary    content=${content}    imgUrlList=${imgUrlList}    mileage=1000    vehicleStyleCode=6    vehicleTypeCode=3
    #发送请求
    ${response}    Post Request    ${add_question}    ${postdata}
    #校验结果
    Should Be Equal As Strings    ${response["code"]}    ${200}
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    SUCCEED

发布问题-参数为空校验
    [Documentation]    【接口信息】
    ...    POST
    ...    - /add-question
    ...
    ...    【测试步骤】
    ...    - 1-5.content、imgUrlList、mileage、vehicleStyleCode、vehicleTypeCode分别不传，发送请求
    ...
    ...    【预期结果】
    ...    - 1.状态码200，body中returnStatus值是FAILED，errorMessage是”需要参数：content“
    ...    - 2.状态码200，body中returnStatus值是SUCCEED
    ...    - 3.状态码200，body中returnStatus值是FAILED，errorMessage是”需要参数：content“
    ...    - 4.状态码200，body中returnStatus值是FAILED，errorMessage是”需要参数：content“
    ...    - 5.状态码200，body中returnStatus值是FAILED，errorMessage是”需要参数：content“
    [Tags]    L2
    #参数准备
    ${content}    Random Eng    100    #随机生成长度为30的英文字符串
    ${imgUrlList }    Create List    &{imgUrlDict}[golf]    &{imgUrlDict}[jetta]
    #步骤1.content不传
    ${postdata}    Create Dictionary    imgUrlList=${imgUrlList}    mileage=1000    vehicleStyleCode=6    vehicleTypeCode=3
    ${response}    Post Request    url=${add_question}    data=${postdata}
    Should Be Equal As Strings    ${response["code"]}    200
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    FAILED
    #步骤2.imgUrlList不传
    ${postdata}    Create Dictionary    content=${content}    mileage=1000    vehicleStyleCode=6    vehicleTypeCode=3
    ${response}    Post Request    url=${add_question}    data=${postdata}
    Should Be Equal As Strings    ${response["code"]}    200
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    SUCCEED
    #步骤3、mileage不传
    ${postdata}    Create Dictionary    content=${content}    imgUrlList=${imgUrlList}    vehicleStyleCode=6    vehicleTypeCode=3
    ${response}    Post Request    url=${add_question}    data=${postdata}
    Should Be Equal As Strings    ${response["code"]}    200
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    FAILED
    #步骤4、vehicleStyleCode不传
    ${postdata}    Create Dictionary    content=${content}    imgUrlList=${imgUrlList}    mileage=1000    vehicleTypeCode=3
    ${response}    Post Request    url=${add_question}    data=${postdata}
    Should Be Equal As Strings    ${response["code"]}    200
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    FAILED
    #步骤5、vehicleTypeCode不传
    ${postdata}    Create Dictionary    content=${content}    imgUrlList=${imgUrlList}    mileage=1000    vehicleStyleCode=6
    ${response}    Post Request    url=${add_question}    data=${postdata}
    Should Be Equal As Strings    ${response["code"]}    200
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    FAILED
    [Teardown]

发布问题-里程校验
    [Tags]    L2
    #构造请求体
    ${content}    Random Chn    100    #随机生成长度为100的字符串
    ${imgUrlList }    Create List    &{imgUrlDict}[golf]    &{imgUrlDict}[jetta]
    ${postdata}    Create Dictionary    content=${content}    imgUrlList=${imgUrlList}    mileage=1000000    vehicleStyleCode=6    vehicleTypeCode=3
    # 发送请求
    ${response}    Post Request    ${add_question}    ${postdata}
    #校验结果
    Should Be Equal As Strings    ${response["code"]}    ${200}
    Should Be Equal As Strings    ${response["body"]["returnStatus"]}    SUCCEED

发布问题-问题描述长度校验
    [Tags]    L2
